{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "class solution:\n",
    "    def reverse(num):\n",
    "        if -10<num<10:\n",
    "            return num\n",
    "        \n",
    "        num_new = abs(num)\n",
    "        str_num = str(num_new)\n",
    "        \n",
    "        if len(str_num)>10:\n",
    "            return 0\n",
    "        \n",
    "        v=''\n",
    "        for i in range(len(str_num)):\n",
    "            v = v + str_num[-(i+1)]\n",
    "            \n",
    "        result = int(v)\n",
    "        \n",
    "        if num<0:\n",
    "            result = -result\n",
    "            \n",
    "        if -2147483648<result<2147483648:\n",
    "            return result\n",
    "        else:\n",
    "            return 0   \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "print(solution.reverse())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
